/*
 * @Author: intellectual seeker 3336339701@qq.com
 * @Date: 2024-12-19 14:32:37
 * @LastEditors: intellectual seeker 3336339701@qq.com
 * @LastEditTime: 2024-12-19 14:50:23
 * @FilePath: /linux-learning/code/lesson23/filetest.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "mystdio.h"

int main()
{
    const char* filename = "./log.txt";

    _myFILE* fp = myfopen(filename, "w");

    char buffer[64] = {0};
    int cnt = 5;
    while(cnt)
    {
        snprintf(buffer, sizeof(buffer), "hello world,hello world %d", cnt--);
        myfwrite(fp, buffer, strlen(buffer));
        DebugPrint(fp);
        sleep(1);
    }

    fork();//子进程销毁时，写时拷贝缓冲区，刷新缓冲区

    myfclose(fp);

    return 0;
}